<?php

/**
 * Flickr Photosets - Map Page
 * Embeds the Google map of the set or photostream.
 * 
 * @author Brad Dougherty <bdougherty@gmail.com>
 * @version 8.2.6
 * @license http://www.gnu.org/licenses/gpl.html GNU General Public License 3.0
 */

/*
Require the function library
This will include all other necessary files
*/
require_once 'lib.php';

/*
Initialize Flickr Photosets and Flickr
*/
$fp = new FlickrPhotosetsCanvas(FlickrPhotosetsCanvas::uid_from_url);

// If this is for a set
if (isset($_GET['sid'])) {
	$tab = 'photosets';
	$photoset = $fp->flickr->photosets_getInfo($_GET['sid']);
	$title = $photoset['title'];
	$url = '<a href="'.$fp->canvas_url.'/photos/'.$fp->uid.'/sets/'.$_GET['sid'].'/">Back to '.$title.'</a>';
	$frame_url = 'uid='.$fp->uid.'&sid='.$_GET['sid'];
	$image = $fp->flickr->buildPhotoUrl($fp->flickr->photos_getInfo($photoset['primary']), 'square');
}
// This is an individual photo
else if (isset($_GET['pid'])) {
	$tab = 'photostream';
	$photo = $fp->flickr->photos_getInfo($_GET['pid']);
	$title = (empty($photo['title'])) ? 'the photo' : $photo['title'];
	$url = '<a href="'.$fp->canvas_url.'/photos/'.$fp->uid.'/'.$_GET['pid'].'/">Back to '.$title.'</a>';
	$frame_url = 'uid='.$fp->uid.'&pid='.$_GET['pid'];
	$image = $fp->flickr->buildPhotoUrl($photo, 'square');
}
// If this is the photostream
else {
	$url = '<a href="'.$fp->canvas_url.'/photos/'.$fp->uid.'/">Back to the photostream</a>';
	$frame_url = 'uid='.$fp->uid.'&pid='.$_GET['pid'];
}

?>

<fb:title>Flickr Map of <?=$title?></fb:title>
<?=$fp->get_stylesheet('map')?>
<?=$fp->get_header($tab, 'Map of '.$title)?>

<div id="summary_bar" class="clearfix">
	
</div>

<div id="map_frame">
	<fb:iframe src="<?=$fp->callback_url?>/map_frame.php?<?=$frame_url?>&amp;h=500" scrolling="no" frameborder="0" width="<?=$fp->fb_sizes['canvas']?>" height="500" />
</div>
	
<?=$fp->echo_footer(true)?>